footer.init();
header.init('成为红人');	

app.ajax(
	'/Goods/Red/lists',
	null,function(res){
		if(res.code == 200){
			app.tpl($('.becomeRed'),'tpl-becomeRed',res);
		}else{
			layer.msg('网络繁忙，请稍候再试');
		}
});
window.onload = function(){
	
	var html1 = $('.explain-text').html();
	var text1 = html1.substr(0,50);
	$('.explain-text').html(text1);
	$('body').on('click','.apply-red',function(){
		var skuId = $(this).attr('data-skuId'),
    		supplierId = $(this).attr('data-supplierId'),
    		warehouseType = $(this).attr('data-warehouseType'),
    		data = {},
    		stock = $(this).attr('data-stock');
    		if(stock <1){
    			layer.msg('库存不足');
    			return false;
    		}
    		data =　{
				supplier_id : supplierId,
    			warehouse_type :warehouseType,
   				skuid :skuId,
    			active_id : 3//  活动  3
    		}
    		app.ajax(
    			'/Goods/Cart/upgradehongren',
 				 data,function(res){
					if(res.code == 200){
						app.open('accout.html','accoutD',{skuid : data.skuid,data1:data},window.location.href,document.body.scrollTop);
					}else{
						layer.msg(res.msg);
					}
    		});
    		return false;
	});
	
	$('body').on('click','.become-list',function(){
			var ids = $('.become-list .apply-red').attr('data-skuId');
			app.open('recomDetail.html','recomDetail',{id : ids},window.location.href,document.body.scrollTop);
			return false;
	});
	
	$('body').on('click','.explain-down',function(){
		if($(this).attr('src').indexOf('down')!= -1){
			$(this).attr('src','../img/icon/up.png');
			$('.explain-text').html(html1);
		}else{
			$(this).attr('src','../img/icon/down.png');
			$('.explain-text').html(text1);
		}
	});
	
};
